feat: Implement LatestContentProvider for WebView recovery#22774
Conversation
Allow GutenbergKit to retrieve the latest content persisted in the host app as needed. This is important for allowing GutenbergKit to display the latest content after the WebView reloads or re-initializes from memory pressure or backgrounding.
|
|
|
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## jkmassel/gutenbergkit-settings-refactor #22774 +/- ##
========================================================================
Coverage 37.40% 37.40%
========================================================================
Files 2320 2320
Lines 123654 123658 +4
Branches 16793 16795 +2
========================================================================
+ Hits 46256 46258 +2
- Misses 73687 73689 +2
Partials 3711 3711 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Integrate an unrelated content loss fix that is necessary for testing this branch's focus on content preservation.
| gravatar = '2.5.0' | ||
| greenrobot-eventbus = '3.3.1' | ||
| gutenberg-kit = 'v0.15.0' | ||
| gutenberg-kit = '432-944fbfce704642cfe725dc69c03b3cf6d5018854' |
There was a problem hiding this comment.
This integrates the bug fix from wordpress-mobile/GutenbergKit#432, which is required for testing the LatestContentProvider's ability to preserve content persistence through WebView reloads.
Once wordpress-mobile/GutenbergKit#432 merges, this should be updated to point to a new release containing that fix.
Project dependencies changeslist! Upgraded Dependencies
org.wordpress.gutenbergkit:android:432-944fbfce704642cfe725dc69c03b3cf6d5018854, (changed from v0.15.0)tree +--- project :libs:editor
-| \--- org.wordpress.gutenbergkit:android:v0.15.0
+| \--- org.wordpress.gutenbergkit:android:432-944fbfce704642cfe725dc69c03b3cf6d5018854
-\--- org.wordpress.gutenbergkit:android:v0.15.0 (*)
+\--- org.wordpress.gutenbergkit:android:432-944fbfce704642cfe725dc69c03b3cf6d5018854 (*) |
jkmassel
left a comment
There was a problem hiding this comment.
Tested on-device, no data loss
| * Returns the persisted post title for content recovery after WebView refresh. | ||
| * @return The most recently persisted title from autosave. | ||
| */ | ||
| String getPersistedTitle(); |
There was a problem hiding this comment.
Because this is a Java file, we should have @ NonNull for this (and getPersistedContent)
0203851
into
jkmassel/gutenbergkit-settings-refactor
* Upgrade GutenbergKit from v0.11.1 to v0.15.0 Adapt to breaking API changes in GutenbergKit v0.15.0: - GutenbergView.createForEditor() removed: use GutenbergView constructor with configuration, dependencies, coroutineScope, and context parameters - gutenbergView.start(config) removed: EditorConfiguration must be provided at construction time - EditorConfiguration moved from org.wordpress.gutenberg to org.wordpress.gutenberg.model - EditorConfiguration.Builder() replaced with EditorConfiguration.builder(siteURL, siteApiRoot, postType) - setPostId(Int?) changed to setPostId(UInt?) - GutenbergView.warmup() removed: warmup helper is now a no-op The fragment's two-phase flow (create view now, start with editor settings later) is replaced by providing the full EditorConfiguration at fragment/view construction time. * feat: Implement LatestContentProvider for WebView recovery (#22774) * feat: Send GutenbergKit the latest content when requested Allow GutenbergKit to retrieve the latest content persisted in the host app as needed. This is important for allowing GutenbergKit to display the latest content after the WebView reloads or re-initializes from memory pressure or backgrounding. * feat: Set GutenbergKit post status * build: Update GutenbergKit version Integrate an unrelated content loss fix that is necessary for testing this branch's focus on content preservation. * build: Update GutenbergKit version to v0.15.1 * build: Integrate GutenbergKit PostTypeDetails API changes (#22784) * build: Integrate GutenbergKit PostTypeDetails API changes Update GutenbergKit to version 446-e44fddffa326f38a3551a5bde9529b060e667a2c and migrate from String-based postType to PostTypeDetails, which encapsulates REST API namespace and base path for different post types. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * build: Update GutenbergKit to v0.15.2 --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * build: Restore comments removed during GutenbergKit v0.15.0 upgrade Re-add section-organizing and explanatory comments that were accidentally dropped in the API migration. Only comments whose described code still exists are restored. * build: Restore KDoc on EditorConfigurationBuilder.build() Re-add the method documentation that was removed during the GutenbergKit v0.15.0 upgrade, minus the stale @param editorSettings that no longer exists. * fix: Delegate getContent() to getTitleAndContent() in GutenbergKit editor getContent() was returning an empty string after the v0.15.0 upgrade. Delegate to getTitleAndContent() and return the content portion so callers get the actual editor content. --------- Co-authored-by: David Calhoun <github@davidcalhoun.me> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>


Description
Ref CMM-1123.
This is a rebased version of #22493 (which was tested and approved). This now targets the
jkmassel/gutenbergkit-settings-refactorbranch (#22764) so it can be reviewed/tested on top of the GutenbergKit v0.15.0 upgrade.Implements GutenbergKit's
LatestContentProviderinterface for pull-based content recovery.When the WebView reinitializes (due to OS memory pressure or page refresh), the editor now requests the latest content from the app rather than using stale content from the initial WebView load. This ensures users don't lose their work during WebView recovery.
Changes:
getPersistedTitle()andgetPersistedContent()methods toEditorFragmentListenerinterfaceLatestContentProvideronGutenbergViewinGutenbergKitEditorFragmentGutenbergKitActivityreturning content fromEditPostRepositoryRebase notes:
EditorConfigurationBuilderto the new builder API:setStatus(...)→setPostStatus(...)and removed the now-redundantsetPostType(...)call (postType is a constructor argument)Related PRs:
Testing instructions
WebView refresh recovery:
chrome://inspect